package com.gmrz.uaf.protocol.v1.schema;

import com.gmrz.util.Convert;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

import java.sql.Timestamp;
import java.util.List;

public class Authenticator {

    @SerializedName("aaid")
    @Expose
    private AAID aaid = null;

    @SerializedName("keyID")
    @Expose
    private KeyID keyID = null;

    @SerializedName("userName")
    @Expose
    private String userName = null;

    private String custNo = null;

    private String uvi = null;
    private String id = null;
    private String specid = null;
    private String key = null;
    private int status = 0;
    private String deviceID = null;
    private int keyFormat;
    private short authenticatorVersion = 0;
    private int signCounter = 0;
    private int regCounter = 0;
    private List<PNGCharacteristics> pngCharacteristics = null;
    private AuthenticatorSpec metadata = null;
    private Timestamp createTimeStamp;
    private Timestamp updateTimeStamp;
    @Expose
    private String appID = null;
    @Expose
    private String authType;
    @Expose
    private String transType;

    private String mobile;
    private String rf1;
    private String rf2;


    @Expose
    private String instCode;


    public String getInstCode() {
        return instCode;
    }

    public void setInstCode(String instCode) {
        this.instCode = instCode;
    }


    private List<String> uvs = null;

    private CertificateBean certificateBean;

    private String custType;

    private String from;

    private String fidoPubkey;

    private CertificateExtendBean certificateExtendBean;

    public CertificateBean getCertificateBean() {
        return certificateBean;
    }

    public void setCertificateBean(CertificateBean certificateBean) {
        this.certificateBean = certificateBean;
    }

    public String getAuthType() {
        return authType;
    }

    public void setAuthType(String authType) {
        this.authType = authType;
    }

    public String getTransType() {
        return transType;
    }

    public void setTransType(String transType) {
        this.transType = transType;
    }

    public String getID() {
        return this.id;
    }

    public void setID(String id) {
        this.id = id;
    }

    public String getSpecDBID() {
        return this.specid;
    }

    public void setSpecDBID(String specid) {
        this.specid = specid;
    }

    public AAID getAAID() {
        return this.aaid;
    }

    public void setAAID(AAID aAID) {
        this.aaid = aAID;
    }

    public void setAAID(String aaid) {
        AAID a = new AAID().parse(aaid);
        this.aaid = a;
    }

    public Authenticator withAAID(AAID aAID) {
        this.aaid = aAID;
        return this;
    }

    public KeyID getKeyID() {
        return this.keyID;
    }

    public void setKeyID(KeyID keyID) {
        this.keyID = keyID;
    }

    public void setKeyID(String base64keyID) {
        KeyID kid = new KeyID();
        byte[] kidBytes = Convert.fromBase64(base64keyID);
        kid.setId(kidBytes);
        this.keyID = kid;
    }

    public void setKeyID(byte[] keyID) {
        KeyID kid = new KeyID().withId(keyID);
        this.keyID = kid;
    }

    public Authenticator withKeyID(KeyID keyID) {
        this.keyID = keyID;
        return this;
    }

    public short getAuthenticatorVersion() {
        return this.authenticatorVersion;
    }

    public void setAuthenticatorVersion(short authenticatorVersion) {
        this.authenticatorVersion = authenticatorVersion;
    }

    public Authenticator withAuthenticatorVersion(short authenticatorVersion) {
        this.authenticatorVersion = authenticatorVersion;
        return this;
    }

    public int getSignCounter() {
        return this.signCounter;
    }

    public void setSignCounter(int signCounter) {
        this.signCounter = signCounter;
    }

    public int getRegCounter() {
        return this.regCounter;
    }

    public void setRegCounter(int regCounter) {
        this.regCounter = regCounter;
    }

    public AuthenticatorSpec getMetadata() {
        return this.metadata;
    }

    public void setMetadata(AuthenticatorSpec data) {
        this.metadata = data;
    }

    public Authenticator withMetadata(AuthenticatorSpec data) {
        this.metadata = data;
        return this;
    }

    public String getPubKey() {
        return this.key;
    }

    public void setPubKey(String key) {
        this.key = key;
    }

    public String getUserName() {
        return this.userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public int getStatus() {
        return this.status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getDeviceID() {
        return this.deviceID;
    }

    public void setDeviceID(String deviceID) {
        this.deviceID = deviceID;
    }

    public int getKeyFormat() {
        return this.keyFormat;
    }

    public void setKeyFormat(int format) {
        this.keyFormat = format;
    }

    public Authenticator withKeyFormat(int format) {
        this.keyFormat = format;
        return this;
    }

    public List<PNGCharacteristics> getPngCharacteristics() {
        return this.pngCharacteristics;
    }

    public void setPngCharacteristics(List<PNGCharacteristics> pngCharacteristics) {
        this.pngCharacteristics = pngCharacteristics;
    }

    public String getUvi() {
        return this.uvi;
    }

    public void setUvi(String uvi) {
        this.uvi = uvi;
    }

    public Timestamp getCreateTimeStamp() {
        return this.createTimeStamp;
    }

    public void setCreateTimeStamp(Timestamp createTimeStamp) {
        this.createTimeStamp = createTimeStamp;
    }

    public Timestamp getUpdateTimeStamp() {
        return this.updateTimeStamp;
    }

    public void setUpdateTimeStamp(Timestamp updateTimeStamp) {
        this.updateTimeStamp = updateTimeStamp;
    }

    public String getAppID() {
        return appID;
    }

    public void setAppID(String appID) {
        this.appID = appID;
    }

    public String getCustNo() {
        return custNo;
    }

    public void setCustNo(String custNo) {
        this.custNo = custNo;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getRf1() {
        return rf1;
    }

    public void setRf1(String rf1) {
        this.rf1 = rf1;
    }

    public String getRf2() {
        return rf2;
    }

    public void setRf2(String rf2) {
        this.rf2 = rf2;
    }

    public List<String> getUvs() {
        return uvs;
    }

    public void setUvs(List<String> uvs) {
        this.uvs = uvs;
    }

    public String getFidoPubkey() {
        return fidoPubkey;
    }

    public void setFidoPubkey(String fidoPubkey) {
        this.fidoPubkey = fidoPubkey;
    }

    public int hashCode() {
        int prime = 31;
        int result = 1;
        result = 31 * result + (this.aaid == null ? 0 : this.aaid.hashCode());

        result = 31 * result + (this.keyID == null ? 0 : this.keyID.hashCode());

        result = 31 * result + (this.userName == null ? 0 : this.userName.hashCode());

        return result;
    }

    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Authenticator other = (Authenticator) obj;

        if (this.aaid == null) {
            if (other.aaid != null)
                return false;
        } else if (!this.aaid.equals(other.aaid)) {
            return false;
        }
        if (this.keyID == null) {
            if (other.keyID != null)
                return false;
        } else if (!this.keyID.equals(other.keyID)) {
            return false;
        }
        if (this.userName == null) {
            if (other.userName != null)
                return false;
        } else if (!this.userName.equals(other.userName)) {
            return false;
        }
        return true;
    }

    public String getCustType() {
        return custType;
    }

    public void setCustType(String custType) {
        this.custType = custType;
    }

    public String getFrom() {
        return from;
    }

    public void setFrom(String from) {
        this.from = from;
    }

    public CertificateExtendBean getCertificateExtendBean() {
        return certificateExtendBean;
    }

    public void setCertificateExtendBean(CertificateExtendBean certificateExtendBean) {
        this.certificateExtendBean = certificateExtendBean;
    }

    @Override
    public String toString() {
        return "Authenticator{" +
                "aaid=" + aaid +
                ", keyID=" + keyID +
                ", userName='" + userName + '\'' +
                ", custNo='" + custNo + '\'' +
                ", uvi='" + uvi + '\'' +
                ", id='" + id + '\'' +
                ", specid='" + specid + '\'' +
                ", key='" + key + '\'' +
                ", status=" + status +
                ", deviceID='" + deviceID + '\'' +
                ", keyFormat=" + keyFormat +
                ", authenticatorVersion=" + authenticatorVersion +
                ", signCounter=" + signCounter +
                ", regCounter=" + regCounter +
                ", pngCharacteristics=" + pngCharacteristics +
                ", metadata=" + metadata +
                ", createTimeStamp=" + createTimeStamp +
                ", updateTimeStamp=" + updateTimeStamp +
                ", appID='" + appID + '\'' +
                ", authType='" + authType + '\'' +
                ", transType='" + transType + '\'' +
                ", mobile='" + mobile + '\'' +
                ", rf1='" + rf1 + '\'' +
                ", rf2='" + rf2 + '\'' +
                ", uvs=" + uvs +
                ", certificateBean=" + certificateBean +
                ", custType='" + custType + '\'' +
                ", from='" + from + '\'' +
                ", certificateExtendBean=" + certificateExtendBean +
                '}';
    }




}
